home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 9866 / 9866.xpi / modules / rss / 2014.jsm next >
Encoding:
Text File  |  2009-09-22  |  2.6 KB  |  95 lines

  1. Components.utils.import("resource://samfind/rss/samfind_modrssutils.jsm");
  2.  
  3. var EXPORTED_SYMBOLS = ["samfindRSSGetLink", "samfindRSSGetTitle", "samfindRSSGetDate", "samfindRSSGetImage", "samfindRSSGetContent"];
  4.  
  5. function samfindRSSGetLink(websiteRssUrl, item)
  6. {
  7.     if (websiteRssUrl == "http://www.oneriot.com/rss/trendingtopics")
  8.     {
  9.         var title = (item.getElementsByTagName("title"))[0];
  10.         if (title)
  11.         {
  12.             return "javascript:samfind_rss._search('" + title.textContent + "');";
  13.         }
  14.     }
  15.     else if (websiteRssUrl.indexOf("twitter.com") != -1)
  16.     {
  17.         var title = (item.getElementsByTagName("title"))[0];
  18.         if (title)
  19.         {
  20.             title = title.textContent;
  21.             var arr = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i.exec(title);
  22.             if (arr)
  23.             {
  24.                 return "javascript:samfind_rss.goTo('" + arr[1] + "');";
  25.             }
  26.         }
  27.     }
  28.     return null;
  29. }
  30.  
  31. function samfindRSSGetTitle(websiteRssUrl, item)
  32. {
  33.     if (websiteRssUrl.indexOf("twitter.com") != -1)
  34.     {
  35.         var title = (item.getElementsByTagName("title"))[0];
  36.         if (title)
  37.         {
  38.             response = title.textContent;
  39.             var start = response.indexOf(":");
  40.             if (start != -1)
  41.             {
  42.                 var end = response.indexOf("http://bit.ly", start);
  43.                 if (end == -1)
  44.                 {
  45.                     end = response.length;    
  46.                 }
  47.                 return response.substring(start + 1, end);
  48.             }
  49.         }
  50.     }
  51.     return null;
  52. }
  53.  
  54. function samfindRSSGetDate(websiteRssUrl, item)
  55. {
  56.     if (websiteRssUrl == "http://www.oneriot.com/rss/trendingtopics")
  57.     {
  58.         return 
  59.     }
  60.     return null;
  61. }
  62.  
  63. function samfindRSSGetImage(websiteRssUrl, item)
  64. {
  65.     return null;
  66. }
  67.  
  68. function samfindRSSGetContent(websiteRssUrl, item, title, link)
  69. {
  70.     if (websiteRssUrl.indexOf("twitter.com") != -1)
  71.     {
  72.         return " ";    
  73.     }
  74.     var content = (item.getElementsByTagNameNS("http://purl.org/rss/1.0/modules/content/", "encoded"))[0];
  75.     if (!content)
  76.     {
  77.         return null;
  78.     }
  79.     var response = content.textContent;
  80.     response = response.replace(/&(lt|gt);/g, function(strMatch, p1){return (p1 == "lt") ? "<" : ">";});
  81.     if (websiteRssUrl != "http://www.oneriot.com/rss/trendingtopics")
  82.     {
  83.         response = response.replace('<table', '<table class="search"');
  84.     }
  85.     response = response.replace(' width="45%"', "");
  86.     response = response.replace(' width="80%"', "");
  87.     response = response.replace(' width="30%"', "");
  88.     response = response.replace(' cellspaing="10"', ' cellspacing="5"');
  89.     response = response.replace("<br/>on", " on");
  90.     response = response.replace("</td></td>", "</td>");
  91.     response = response.replace("this.src='/", "this.src=");
  92.     response = samfind_modrssutils.HTML2Unicode(response);
  93.     response = response.replace("&", "&", "g");
  94.     return response;
  95. }